from pymongo import MongoClient

# 实例化client，建立连接
client = MongoClient(host="10.211.55.5", port=27017)
collection = client["test"]["t251"]

#  插入一条数据
# ret = collection.insert_one({"name": "xiaowang", "age": 10})
# print(ret)

# 插入多条数据
# data_list = [{"name": "test{}".format(i)} for i in range(10)]
# collection.insert_many(data_list)

# 查询一个记录
# t = collection.find_one({"name":"xiaowang"})
# print(t)

# 查询所有记录
t = collection.find({"name":"xiaowang"})
print(list(t))

